import { reqCategoryList, reqGetBannerList, reqGetFloorList } from "@/api"
// home 模块小仓库
const state = {
  categoryList: [],
  bannerList: [],
  floorList: []
}
const mutations = {
  CATEGORYLIST (state, categoryList) {
    state.categoryList = categoryList
  },
  BANNERLIST (state, bannerList) {
    state.bannerList = bannerList
  },
  FLOORTLIST (STATE, floorList) {
    state.floorList = floorList
  }
}
const actions = {
  // 通过API里面的接口函数调用，向服务器发请求，获取服务器的数据
  async categoryList (context) {
    const {data: res} = await reqCategoryList ()
    if (res.code == 200){
      context.commit('CATEGORYLIST', res.data)
    }
  },
  // 获取首页轮播图
  async getBannerList (context) {
    const {data: res} = await reqGetBannerList ()
    if (res.code == 200) {
      context.commit ('BANNERLIST', res.data)
    }
  },
  // 获取floor组件数据
  async getFloorList (context) {
    const {data: res} = await reqGetFloorList ()
    if (res.code == 200) {
      context.commit ('FLOORTLIST', res.data)
    }
  }
}
const getters = {}

export default {
  state,
  mutations,
  actions,
  getters
}